package render;

import geom.Geometry;

/**
 * plane primitive
 * 
 * @author Robbe
 *
 */

public class Plane implements Primitive {
	
	double n[];
	double d;
	Material material;
	
	public Plane(double[] n, double d, Material material) {
		this.n = n;
		this.d = d;
		this.material = material;
	}

	public double intersection(double[] x, double[] d) {
		double denominator = Geometry.dotProduct(n, d);
		if (denominator == 0) {
			// no intersection
			return Double.NaN;
		} else {
			// one (and only) intersection
			return -(Geometry.dotProduct(n, x) + this.d) / denominator;
		}
	}
	
	public Postion inHalfSpace(double m, int axis) {
		// TODO Auto-generated method stub
		return Postion.BOTH;
	}
	
	public double[] getPostion() {
		// TODO Auto-generated method stub
		return Geometry.product(n, d);
	}

	public Material getMaterial() {
		return material;
	}

	public double[] getNormal(double[] p) {
		// TODO Auto-generated method stub
		return n;
	}
}
